/**
 * 热点库导出为csv
 */
const { db } = require('../db-helper');
const fs = require('fs')

const QUERY_SQL = "select groupId, artifactId, version from maven"


let list = db.query(QUERY_SQL)

console.log('条数：' + list.length)

let i = 1

let content = 'id, groupId, artifactId, version\r\n'
content += list
    .map(row => `"${i++}","${row.groupId}","${row.artifactId}","${row.version}"`)
    .join('\r\n')


fs.writeFileSync('maven.csv', content, {encoding: "utf-8"})